/**
 * 
 */
package com.google.code.netz.wfe.api;

import com.google.code.netz.wfe.model.IPetriNetEntity;

/**
 * Specifies a contract for {@link ILifecycleHandler} extensions. Essentially we
 * can start a entity that needs to have a lifecycle.
 * <p>
 * Extensions of {@link ILifecycleHandler} are ideally stateless such that they
 * can be used by different clients to manage same {@link IPetriNetEntity}
 * instance.
 * 
 * @author <a href='mailto:rahul.thakur.xdev@gmail.com'>Rahul Thakur</a>
 * @since 1.0
 * @version $Id$
 */
public interface ILifecycleHandler<E extends IManaged> {

	/**
	 * Initializes and starts processing/executing the specified entity.
	 * 
	 * @param <E>
	 * @param entity
	 * @param workflowContext
	 * @throws WorkflowException
	 */
	public void start(E entity, Object workflowContext) throws WorkflowException;

	/**
	 * Terminates and performs necessary cleanups for a specified entity.
	 * 
	 * @param <E>
	 * @param entity
	 * @param workflowContext
	 * @throws WorkflowException
	 */
	public void stop(E entity, Object workflowContext) throws WorkflowException;

	/**
	 * Suspends a Workflow entity that is currently active and
	 * processing/executing.
	 * 
	 * @param <E>
	 * @param entity
	 * @param workflowContext
	 * @throws WorkflowException
	 */
	public void suspend(E entity, Object workflowContext) throws WorkflowException;

	/**
	 * Resumes a specified workflow entity from its suspended state.
	 * 
	 * @param <E>
	 * @param entity
	 * @param workflowContext
	 * @throws WorkflowException
	 */
	public void resume(E entity, Object workflowContext) throws WorkflowException;

}
